package com.example.demo.controller.base;

import com.example.demo.common.AjaxResult;
import com.example.demo.common.TableDataInfo;

public class BaseController {

    protected TableDataInfo dataInfo(Object rows, Long total){

        TableDataInfo dataInfo = new TableDataInfo();
        dataInfo.setCode(200);
        dataInfo.setMsg("查询成功");
        dataInfo.setRows(rows);
        dataInfo.setTotal(total);

        return dataInfo;
    }

    /**
     * 根据影响行数判断结果
     * @param row
     * @return
     */
    protected AjaxResult toAjax(int row){
        return row > 0 ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 根据布偶值判断结果
     * @param row
     * @return
     */
    protected AjaxResult toAjax(boolean row){
        return row ? AjaxResult.success() : AjaxResult.error();
    }
}
